package Thread_.homework;

class MyThread02 implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("Thread2 run");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class test2 {
    public static void main(String[] args) {
        //2.通过实现Runnable接口创建线程
        MyThread02 runnable = new MyThread02();
        Thread thread = new Thread(runnable);
        thread.start();
        while(true){
            System.out.println("main ");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
